package com.epro.dx.task;

import com.epro.dx.listenner.MyAsyncTaskListenner;
import com.epro.dx.util.ActivityUtil;
import com.weipu.common.facade.exception.DxException;
import com.weipu.common.facade.factory.ProviderFactory;

import android.content.Context;
import android.os.AsyncTask;

/************************
 * @author Tony
 * @Date:2016-4-29下午3:20:30
 * @描述:收到消息后的回执接口任务
 ************************/
public class FeedBackNoticeAsyncTask extends
	BaseNeedReLoginTask {

	private String backNotice = null;
	private String noticeID;
	private MyAsyncTaskListenner myAsyncTaskListenner;
	private Context mContext;
	public FeedBackNoticeAsyncTask(Context mContext,String noticeID,MyAsyncTaskListenner MyAsyncTaskListenner){
		this.mContext = mContext;
		this.noticeID = noticeID;
		myAsyncTaskListenner = MyAsyncTaskListenner;
	}
	@Override
	protected void onPreExecute() {
		if(null!=myAsyncTaskListenner){
			myAsyncTaskListenner.onPreTask();
		}
		super.onPreExecute();
	}
	@Override
	protected String doInBackground(Void... params) {
		try {
			backNotice = ProviderFactory.createMessageService().feedBackNotice(ActivityUtil.getCustomerID(),
					ActivityUtil.getCustomerToken(), noticeID);
		} catch (DxException e) {
			return e.getErrCode();
		}
		return "0";
	}
	@Override
	protected void onPostExecute(String result) {
		super.onPostExecute(result);
		if(null!=myAsyncTaskListenner && !isRelogin){
			myAsyncTaskListenner.onPostTask(result, backNotice);
		}
	}
	@Override
	protected Context setContext() {
		return mContext;
	}
	@Override
	protected BaseNeedReLoginTask setTask() {
		return new FeedBackNoticeAsyncTask(mContext, noticeID, myAsyncTaskListenner);
	}

}
